﻿import QtQuick 2.0
import QtCharts 2.2
import QtQuick.Controls 1.4

Item {
    //    /color: Qt.transparent//Qt.rgba(Math.random(),Math.random(),Math.random(),0.8)
    width: 400
    height: 400
    property string classname: ""
    signal signalQmlOptions(var v1,var v2);
    Text {
        id: xxxxx
        text: qsTr("%1内嵌qml,背景颜色是%1的 点击改变背景颜色").arg(classname)
        font.pixelSize: 20
        width: parent.width
        height: 40
        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter
    }
    function setTitle(title){
        classname = title;
    }
    MouseArea{
        id:ma
        anchors.fill: parent
        onClicked: {
            //xx.borderColor = Qt.rgba(Math.random(),Math.random(),Math.random(),1.0);
            var color = Qt.rgba(Math.random(),Math.random(),Math.random(),0.8);
            signalQmlOptions("changedcolor",color);
        }
    }
    NewFlickView{
        id:xx
        anchors.fill: parent
        anchors.margins:10
        anchors.topMargin: 40
        myModel: hitModel
        header: NewHeader{
            id:sc
            height: 700
            width: xx.width
        }
    }
    ListModel{
        id:hitModel
        Component.onCompleted: {
            for(var i=0;i<100;i++){
                 hitModel.append({name:i+ "1221212"})
            }
        }
    }
    function checkUrl(urlString){
        if(urlString!=""){
            var reg=/(http|ftp|https|view):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/;
            if(!reg.test(urlString)){
                console.log("不是正确的网址吧，请注意检查一下",urlString);
            }else{
                console.log("正确--------",urlString)
            }
        }
        isURL(urlString)
    }
    function isURL(str_url){
        var strRegex = "^((https|http|ftp|rtsp|mms|view)?://)"
                + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp的user@
                + "(([0-9]{1,3}/.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184
                + "|" // 允许IP和DOMAIN（域名）
                + "([0-9a-z_!~*'()-]+/.)*" // 域名- www.
                + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]/." // 二级域名
                + "[a-z]{2,6})" // first level domain- .com or .museum
                + "(:[0-9]{1,4})?" // 端口- :80
                + "((/?)|" // a slash isn't required if there is no file name
                + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
        var re=new RegExp(strRegex);
        //re.test()
        if(!re.test(str_url)){
            console.log("不是正确的网址吧，请注意检查一下",str_url);
        }else{
            console.log("正确--------",str_url)
        }
    }
}
